package represent.type;

public class BoolType implements Type {

	private Boolean val;

	public BoolType(String s) {
		val = new Boolean(s);
	}
	
	public BoolType(Boolean b) {
		val = b;
	}

	public Object asJavaVal() {
		return val;
	}

	public boolean equals(Object o) {
		BoolType bv = (BoolType) o;
		return val != null && val.equals(bv.val);
	}

	public int hashCode() {
		return val.hashCode();
	}

	public String toString() {
		return val.toString();
	}

	public Type divide(Type c) {
		throw new Error("Undefined operation.");
	}

	public String getType() {
		return "boolean";
	}

	public Type minus(Type c) {
		throw new Error("Undefined operation.");
	}

	public Type mod(Type c) {
		throw new Error("Undefined operation.");
	}

	public Type mult(Type c) {
		throw new Error("Undefined operation.");
	}

	public Type plus(Type constant) {
		throw new Error("Undefined operation.");
	}

	public int compareTo(Type o) {
		BoolType bv = (BoolType) o;
		return val.compareTo(bv.val);
	}

	public static int compare(byte[] a, byte[] b) {
		// TODO �Զ���ɷ������
		return 0;
	}

	public static BoolType fromBytes(byte[] bytes) {
		// TODO implement it
		return null;
	}

	public int TypeToInt() {
		return utils.Constant.BOOL;
	}
	
	public static int length() {
		return 1;
	}

}
